<template>
	<view class="container">
		<view class="incontainer">
			<view class="Pre">
				<view class="Prein">
					<view class="text"><text class="color"> * </text>预约人 </view>
					<view class=""><input type="text" style="margin-left: 30rpx;" placeholder="请输入姓名" /></view>
				</view>
				<view class="Prein">
					<view class="text"><text class="color"> *</text>预约时间</view>
					<view style="margin-top: -100rpx;">
						<u-calendar :show="show"></u-calendar>
						<u-button @click="show = true">打开</u-button>
					</view>
				</view>
				<view class="Prein">
					<view class="text"><text class="color"> *</text>当前住址</view>
					<view class=""><input type="text" placeholder="请填写当前住址" /></view>
				</view>
				<view class="Prein">
					<view class="text"><text class="color"> *</text>手机号码</view>
					<view class=""><input type="text" placeholder="请输入手机号" /></view>
				</view>
			</view>
			<view class="content">
				<view class="text" style="margin-left: 20rpx; font-size: 28rpx;">
					维修内容
				</view>
				<view class="">
					<u--textarea v-model="value2" placeholder="请输入内容" count></u--textarea>
				</view>
			</view>
			<view class="upload-five" style="  margin-left: 30rpx;font-weight: bold;font-size: 28rpx;">
				上传维修图片(最多上传5张照片)
			</view>
			<view class="upload" style=" display: flex; ">
				<view class="uploadin">
					<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
						:maxCount="1" width="90" height="55" uploadText="点击上传"></u-upload>
				</view>
				<view class="uploadin">
					<u-upload :fileList="fileList2" @afterRead="afterRead" @delete="deletePic" name="2" multiple
						:maxCount="1" width="90" height="55" uploadText="点击上传"></u-upload>
				</view>
				<view class="uploadin">
					<u-upload :fileList="fileList3" @afterRead="afterRead" @delete="deletePic" name="3" multiple
						:maxCount="1" width="90" height="55" uploadText="点击上传"></u-upload>
				</view>
			</view>
			<view class="uploadtwo" style="display: flex;">
				<view class="uploadin">
					<u-upload :fileList="fileList4" @afterRead="afterRead" @delete="deletePic" name="4" multiple
						:maxCount="1" width="90" height="55" uploadText="点击上传"></u-upload>
				</view>
				<view style="margin-left: 28rpx;" class="uploadin">
					<u-upload :fileList="fileList5" @afterRead="afterRead" @delete="deletePic" name="5" multiple
						:maxCount="1" width="90" height="55" uploadText="点击上传"></u-upload>
				</view>
			</view>
		</view>
		<view class="Submit">
			<u-button type="primary" text="提交"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileList1: [],
				fileList2: [],
				fileList3: [],
				fileList4: [],
				fileList5: [],
				show: false,
				value2: '统计字数',
			};
		},
		methods: {
			show(e) {
				console.log(e);
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: 'http://192.168.2.21:7001/upload', // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						success: (res) => {
							setTimeout(() => {
								resolve(res.data.data)
							}, 1000)
						}
					});
				})
			},
		}

	}
</script>

<style lang="scss">
	.container {
		width: 100vw;
		height: 100vh;
		border: 1rpx solid #ccc;
		background-color: #ececec;

		.incontainer {
			width: 90%;
			height: 1000rpx;
			background-color: white;
			border-radius: 10px;
			border: 1rpx solid #ccc;
			position: absolute;
			top: 30rpx;
			left: 35rpx;

			.Pre view {
				// border: 1rpx solid #ccc;
				height: 80rpx;
				margin-left: 10rpx;
				margin-top: 25rpx;
			}

			.Prein {
				width: 95%;
				border-bottom: 1rpx solid #f3f3f3;
				display: flex;
				padding-left: -50rpx;

				// border: 1rpx solid #ccc;
				.text {

					font-weight: bold;
					font-size: 28rpx;
				}
			}

			.color {
				color: red;
			}

			.upload {
				width: 90%;

				display: flex;
				margin-top: 20rpx;

				.uploadin {
					border-radius: 60px 0px 0px 0px;
					margin-left: 25rpx;
				}
			}

			.content {
				width: 95%;
				// border: 1rpx solid #ccc;
				margin-left: 12rpx;
				margin-top: 30rpx;

				.text {
					font-weight: bold;
				}
			}

			.upload-five {
				margin-top: 0rpx;
			}
		}

		.uploadtwo {
			margin-left: 25rpx;
		}

		.Submit {
			position: absolute;
			top: 1100rpx;
			width: 90%;
			left: 37rpx;
		}

		.nav {
			width: 90%;
			height: 200rpx;
		}
	}
</style>
